const app = getApp()
const db = wx.cloud.database({
  env: 'cloud1-2g6vpgs796710242'
})
var list_value = []

Page({
  data: {
    libData:[],
    evalue:list_value,
    //下方弹窗参数
    show: false,
    duration: 300,
    position: 'right',
    round: true,
    overlay: true,
    customStyle: '',
    overlayStyle: '',
  },

  onLoad: function (options) {
    list_value.splice(0, list_value.length)
    console.log("记录id",options.id)
    db.collection("DS_risk")
    .doc(options.id)
    .get()
    .then(res=>{
      console.log("目标记录",res)
      this.setData({
        libData:res.data
      })
      res.data.label.forEach(element=>{
        element.arguments.forEach(subele=>{
          var earr = {"body":"","time":"","data":""}
          if (JSON.stringify(subele).slice(2,5)==="主体") {
            earr.body==JSON.stringify(subele).slice(7,-2)
          } else if (JSON.stringify(subele).slice(2,5)==="时间") {
            earr.time==JSON.stringify(subele).slice(7,-2)
          } else if (JSON.stringify(subele).slice(2,5)==="数值") {
            earr.data==JSON.stringify(subele).slice(8,-3)
          }
          list_value = list_value.concat(earr)
        })
      })
      console.log("对应值",list_value)
    })
    .catch(err=>{
      console.log(err)
    })
  },

  pop_cabinet() {
    const position = "bottom"
    let customStyle = ''
    let duration = this.data.duration
    switch (position) {
      case 'top':
      case 'bottom':
        customStyle = 'height: 30%;'
        break
      case 'right':
        break
    }
    this.setData({
      position,
      show: true,
      customStyle,
      duration
    })
  },

})